import java.util.*;

public class BinInsert {
    public static int binInsert(int n, int m, int j, int i) {
        // write code here
        String str1 = Integer.toBinaryString(n);
        String str2 = Integer.toBinaryString(m);
        char[] chars = str1.toCharArray();
        int  mLen = str2.length()-1;
        for (int k = str1.length()-j-1; k > str1.length()-j-1-str2.length(); k--) {
            chars[k] = str2.charAt(mLen--);
        }
        StringBuilder stringBuilder = new StringBuilder();
        for (char ch : chars) {
            stringBuilder.append(ch);
        }
        return Integer.parseUnsignedInt(stringBuilder.toString(), 2);
    }

    public static void main(String[] args) {
        // System.out.println(Integer.toBinaryString(19));
        System.out.println(binInsert(4355,4,2,7));
    }
}